#!/bin/bash

# 获取构建时间
BUILT=$(date '+%Y-%m-%d %H:%M:%S')

# 检查是否提供版本号参数
if [ -z "$1" ]; then
  echo "Usage: $0 <version>"
  exit 1
fi
# 设置版本号
VERSION=$1

# 获取最后一次提交的 Git Commit
GITCOMMIT=$(git rev-parse HEAD)

# 构建命令
go build -v -ldflags " \
-X 'gitee.com/night-tc/gobige/global.Built=$BUILT' \
-X 'gitee.com/night-tc/gobige/global.Version=$VERSION' \
-X 'gitee.com/night-tc/gobige/global.Gitcommit=$GITCOMMIT' \
" -o ../bin ./...
